package com.zhouwr.common.metadata;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.zhouwr.common.enums.ModelDataType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @program: forallcn-iotps
 * @description:
 * @author: zhouwr
 * @create: 2020-11-26 22:34
 * @version：1.0
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ArrayData extends Metadata<String> {
    private Integer arraySize = 0;
    private String arrayType;
    private String arraySplit = " ";
    @JsonInclude()
    private String defaultValue = null;
    private ModelDataType type = ModelDataType.ARRAY;


    @Override
    public String getDefaultValue() {
        return this.defaultValue;
    }

    public static Metadata<?> form(String metadata) {
        return JSON.toJavaObject(JSON.parseObject(metadata), ArrayData.class);
    }
}
